package repl

import (
	"strconv"
	"strings"

	"github.com/fatih/color"
)

// 语法高亮
func highlight(input string) string {
	// 简单关键词高亮
	keywords := []string{"func", "let", "if", "else", "return"}
	for _, kw := range keywords {
		if strings.Contains(input, kw) {
			input = strings.ReplaceAll(input, kw, color.GreenString(kw))
		}
	}

	// 数字高亮
	if _, err := strconv.ParseFloat(input, 64); err == nil {
		return color.YellowString(input)
	}

	return input
}
